package edu_xy.hm_02.slice;

import edu_xy.hm_02.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image;
/*
    * 页面由两部分构成
    * 页面布局代码   xml
    * 后台逻辑代码   java

*/

public class MainAbilitySlice05 extends AbilitySlice {
    Image image=null;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 所关联的页面布局代码   xml
        super.setUIContent(ResourceTable.Layout_ability_main_05);

        // 获取布局对象和图形组件对象
        DirectionalLayout layout = (DirectionalLayout)this.findComponentById(ResourceTable.Id_layout05);
        image= (Image)this.findComponentById(ResourceTable.Id_image_05_01);

        layout.setDoubleClickedListener(this::doubleClickedListenerLayout);
        image.setDoubleClickedListener(this::doubleClickedListenerImage);


    }

    private void doubleClickedListenerLayout(Component component) {
        image.setImageAndDecodeBounds(ResourceTable.Media_red);
    }

    private void doubleClickedListenerImage(Component component) {
        image.setImageAndDecodeBounds(ResourceTable.Media_white);
    }




    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}